/**
 * [119] 杨辉三角 II
 *
 * @format
 * @lc app=leetcode.cn id=119 lang=javascript
 */

// @lc code=start
/**
 * @param {number} rowIndex
 * @return {number[]}
 */
var getRow = function (rowIndex) {
    const result = Array(rowIndex + 1)
    for (let i = 0; i < rowIndex + 1; i++) {
        result[i] = new Array(i + 1)
        result[i][0] = result[i][i] = 1
    }
    for (let i = 2; i < rowIndex + 1; i++) {
        for (let j = 1; j < i; j++) {
            result[i][j] = result[i - 1][j - 1] + result[i - 1][j]
        }
    }
    return result[rowIndex]
}
// @lc code=end
